﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Sinacor.OMM.HealthMonitor.Entity.Common;
using Sinacor.OMM.HealthMonitor.Entity.Msmq;

namespace Sinacor.OMM.HealthMonitor.Entity.Router
{
    [Serializable()]
    public class RouterData : HealthEntityBase, IHealthDataReset
    {
        public RouterData()
            : base(HealthType.Router)
        {
            MessageReceiverInfo = new MessageReceiver(this);
            MessageRouterInfo = new MessageRouter(this);
            DataBaseProcessInfo = new DataBaseProcess(this);
            ProcessDataInfo = new ProcessData(this);
            _msmqRouter = new MsmqData(this);
            _errorData = new ErrorData(this);
        }

        private MessageReceiver _messageReceiver;
        public MessageReceiver MessageReceiverInfo
        {
            get { return _messageReceiver; }
            set 
            { 
                _messageReceiver = value;
                this.LastUpdate = DateTime.Now;
            }
        }

        private MessageRouter _messageRouter;
        public MessageRouter MessageRouterInfo
        {
            get { return _messageRouter; }
            set 
            { 
                _messageRouter = value;
                this.LastUpdate = DateTime.Now;
            }
        }

        private DataBaseProcess _dataBaseProcess;
        public DataBaseProcess DataBaseProcessInfo
        {
            get { return _dataBaseProcess; }
            set 
            { 
                _dataBaseProcess = value;
                this.LastUpdate = DateTime.Now;
            }
        }

        private ProcessData _processData;
        public ProcessData ProcessDataInfo
        {
            get { return _processData; }
            set 
            { 
                _processData = value;
                this.LastUpdate = DateTime.Now;
            }
        }

        // Roteador parado por alguma fila exceder o limite de mensagens
        private bool _stopedBySomeQueueExceedsLimit;
        public bool StopedBySomeQueueExceedsLimit
        {
            get { return _stopedBySomeQueueExceedsLimit; }
            set 
            { 
                _stopedBySomeQueueExceedsLimit = value;
                this.LastUpdate = DateTime.Now;
            }
        }

        // Limite Roteador parado por alguma fila exceder o limite de mensagens
        private bool _limitStopedBySomeQueueExceedsLimit;
        public bool LimitStopedBySomeQueueExceedsLimit
        {
            get { return _limitStopedBySomeQueueExceedsLimit; }
            set 
            { 
                _limitStopedBySomeQueueExceedsLimit = value;
                this.LastUpdate = DateTime.Now;
            }
        }

        // Fila MSMQ do Router
        private MsmqData _msmqRouter;
        public MsmqData MsmqRouter
        {
            get { return _msmqRouter; }
            set 
            { 
                _msmqRouter = value;
                this.LastUpdate = DateTime.Now;
            }
        }

        private ErrorData _errorData;

        public ErrorData ErrorData
        {
            get { return _errorData; }
            set
            {
                _errorData = value;
                this.LastUpdate = DateTime.Now;
            }
        }

        public void Reset()
        {
            ErrorData.Reset();
            MessageReceiverInfo.Reset();
            MessageRouterInfo.Reset();
            DataBaseProcessInfo.Reset();
            ProcessDataInfo.Reset();
            MsmqRouter.Reset();
            StopedBySomeQueueExceedsLimit = false;
        }
    }
}
